
#ifndef  _FLASH_CIPHER_H_
#define  _FLASH_CIPHER_H_


void flash_cipher_buf_init(UINT8 *tmp_buf_addr, UINT32 tmp_buf_size);

INT32 encrypt_universal_key(UINT32 key_id);
INT32 decrypt_universal_key(UINT8 *pos, UINT32 key_chunk_id);
INT32 aes_cbc_decrypt_ram_chunk(UINT8 key_pos, UINT8 *out, UINT8 *data, UINT32 data_len);
INT32 aes_cbc_decrypt_flash_data(UINT8 key_pos, UINT32 block_addr, UINT32 block_len, UINT8 *out);
INT32 aes_cbc_decrypt_chunk(UINT8 key_pos, UINT32 blockid, UINT8 *out, UINT32 *len);
/*
add for three key ladder to encrpt or decrypt
*/
INT32  decrypt_universal_key_ext(UINT32 key_chunk_id,UINT8*key);
INT32 aes_cbc_decrypt_chunk_ext(UINT8* key, UINT32 blockid, UINT8 *out, UINT32 *len);
INT32 aes_cbc_decrypt_flash_data_ext(UINT8* key, UINT32 block_addr, UINT32 block_len, UINT8 *out);
INT32 encrypt_universal_key_ext(UINT32 key_id);
/*end*/

#define BL_VER    0
#define SW_VER   1
#define OTP_ADDESS_BL_VER    0x74
#define OTP_ADDESS_SW_VER   0x78
#define MAX_VERSION_NUM        128

BOOL version_update(unsigned long new_version, unsigned char flag);

#endif /*_FLASH_CIPHER_H_*/
